package com.chunyu.app.utils;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.codec.binary.Base64;


public class JSONFile {
	private String fileName;
	private String fileFolder;
	private String fileUrl;
	private String fileBody;

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public String getFileFolder() {
		return fileFolder;
	}

	public void setFileFolder(String fileFolder) {
		this.fileFolder = fileFolder;
	}

	public String getFileBody() {
		return fileBody;
	}

	public void setFileBody(String fileBody) {
		this.fileBody = fileBody;
	}

	public JSONFile(String fileName) {
		super();
		this.fileName = fileName;
	}

	/**
	 * 导入数据信息
	 * 
	 * @param basePath
	 * @param fileNames
	 * @return
	 */
	public static String loadFiles(String basePath, String... fileNames) {
		List<JSONFile> ret = new ArrayList<JSONFile>();
		for (String fileName : fileNames) {
			JSONFile file = new JSONFile(fileName);
			file.setFileBody(Base64.encodeBase64String(FileUtils.readBytes(basePath + fileName)));
			ret.add(file);
		}
		if (ret.isEmpty()) {
			return null;
		} else {
			return JsonUtils.toJson(ret);
		}
	}

	public String getFileUrl() {
		return fileUrl;
	}

	public void setFileUrl(String fileUrl) {
		this.fileUrl = fileUrl;
	}
	
	
}
